package com.insurance.service.impl;

import com.insurance.mapper.DriverMapper;
import com.insurance.pojo.Driver;
import com.insurance.service.DriverService;
import com.insurance.utils.ConversionDateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


/**
 * Created with IntelliJ IDEA.
 * User: yjc
 * Date: 2020/10/27 17:08
 * Description:
 * Version: V1.0
 */
@Service
public class DriverServiceImpl implements DriverService {
    @Autowired(required = false)
    private DriverMapper driverMapper;

    @Override
    public List<Map> queryDriverById(Driver driver) {
        return driverMapper.queryDriverById(driver);
    }

    @Override
    public int queryByProvinceDriver(Driver driver) {
        return driverMapper.queryByProvinceDriver(driver);
    }

    @Override
    public int queryByCityDriver(Driver driver) {
        return driverMapper.queryByCityDriver(driver);
    }

    @Override
    public int queryByAreaDriver(Driver driver) {
        return driverMapper.queryByAreaDriver(driver);
    }

    @Override
    public int downDriver(Driver driver) {
        return driverMapper.downDriver(driver);
    }

    @Override
    public int queryOrder(Driver driver) {
        return driverMapper.queryOrder(driver);
    }

    @Override
    public int updateDriverStatus(Driver driver) {
        return driverMapper.updateDriverStatus(driver);
    }

    @Override
    public int queryMessageByUserId(Driver driver) {
        return driverMapper.queryMessageByUserId(driver);
    }

    @Override
    public int updateDriverPwd(Driver driver) {
        return driverMapper.updateDriverPwd(driver);
    }

    @Override
    public List<Map> queryDriverOrder(Driver driver) {
        List<Map> list = driverMapper.queryDriverOrder(driver);
        for (Map map:list){
            if (map.get("expectfinish_time") != null){
                String date= ConversionDateUtils.conversionDateStringUtils(map.get("expectfinish_time"));
                map.put("expectfinish_time",date);
            }
            if (map.get("car_alsotime") != null){
                String date= ConversionDateUtils.conversionDateStringUtils(map.get("car_alsotime"));
                map.put("car_alsotime",date);
            }
            if (map.get("car_picktime") != null){
                String date= ConversionDateUtils.conversionDateStringUtils(map.get("car_picktime"));
                map.put("car_picktime",date);
            }
            if (map.get("order_time") != null){
                String date= ConversionDateUtils.conversionDateStringUtils(map.get("order_time"));
                map.put("order_time",date);
            }
        }
        return list;
    }

    @Override
    public int updateDriverOrderStatus(Driver driver) {
        return driverMapper.updateDriverOrderStatus(driver);
    }

    @Override
    public int updateDriverOrderPicktime(Driver driver) {
        return driverMapper.updateDriverOrderPicktime(driver);
    }
}
